package com.ybkj.daijia.template.em;

import freemarker.template.TemplateMethodModelEx;
import freemarker.template.TemplateModelException;
import java.io.IOException;
import java.util.List;
import java.util.Properties;
import org.apache.commons.lang3.BooleanUtils;
import org.springframework.core.io.support.PropertiesLoaderUtils;

public class ZuOrZhuanMethodTag implements TemplateMethodModelEx {

    @Override
    public Object exec(List arguments) throws TemplateModelException {

        Properties properties;
        boolean show = false;
        try {
            properties = PropertiesLoaderUtils
                .loadAllProperties("config.properties", ZuOrZhuanMethodTag.class.getClassLoader());
            boolean zu_show = BooleanUtils
                .toBoolean(properties.getProperty("function.zuche.open", "false"));

            boolean zhuan_show = BooleanUtils
                .toBoolean(properties.getProperty("function.zhuanche.open", "false"));

            if (zu_show || zhuan_show) {
                show = true;
            }

        } catch (IOException e) {
            e.printStackTrace();
        }

        return show;
    }

}
